<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>列表渲染</title>
</head>

<body>
    <div id="root">
        <h2>人员列表</h2>
        <ul>
            <!-- 多个对象 -->
            <!-- <li v-for="(a,b) in persons" >{{a}}-{{b}}</li> -->

            <!-- <li v-for="p in persons" :key="p.id">{{p.name}}-{{p.age}}</li> -->
            <!--    for  in 建议遍历对象  -->
            <li v-for="(car,key) in car" :key="key"> {{car}}-{{key}}</li>
            
            <!-- for  of 建议遍历数组 -->
            <li v-for="(p,index) of persons" :key="index"> {{p.name}}-{{p.age}}</li>

            <!-- for of 数字 指定遍历次数 -->
            <li v-for="(number,index) of 6" :key="index"> {{index}}-{{number}}</li>
        </ul>
    </div>

    <script>
        const vm = new Vue({
            el: "#root",
            data: {
                persons: [
                    { id: "002", name: "李四", age: 25 },
                    { id: "003", name: "王五", age: 20 },
                    { id: "001", name: "张三", age: 18 },

                ],
                car: {
                    name: "奥迪双钻",
                    color: "蓝红",
                    price: "200W"

                }
            },

        })
    </script>
</body>

</html>